<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>RVM : Debugging the RVM</title>
	    <link rel="stylesheet" href="styles/site.css" type="text/css" />
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">	    
    </head>

    <body>
	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
		    <tr>
			    <td valign="top" class="pagebody">
				    <div class="pageheader">
					    <span class="pagetitle">
                            RVM : Debugging the RVM
                                                    </span>
				    </div>
				    <div class="pagesubheading">
					    This page last changed on Mar 24, 2008 by <font color="#0050B2">steveblackburn</font>.
				    </div>

				    <p>There are different tools for debugging Jikes RVM:</p>

<h2><a name="DebuggingtheRVM-GDB"></a>GDB</h2>

<p>There is a limited amount of C code used to start Jikes RVM. The rvm script will start Jikes RVM using GDB (the GNU debugger) if the first argument is <tt>&#45;gdb</tt>. Break points can be set in the C code, variables, registers can be expected in the C code.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>rvm -gdb &lt;RVM args&gt; &lt;name of Java application&gt; &lt;application args&gt;
</pre>
</div></div>
<p>The dynamically created Java code doesn't provide GDB with the necessary symbol information for debugging. As some of the Java code is created in the boot image, it is possible to find the location of some Java methods and to break upon them. To determine the location use the RVM.map file. A script to enable use of the RVM.map as debugger information inside GDB is provided <a href="http://sourceforge.net/tracker/index.php?func=detail&amp;aid=1160674&amp;group_id=128805&amp;atid=723235">here</a>.</p>

<h2><a name="DebuggingtheRVM-OtherTools"></a>Other Tools</h2>

<p>Other tools, such as valgrind, are occasionally useful in debugging or understanding the behaviour of JikesRVM.&nbsp; The rvm script facilitates using these tools with the '-wrap' argument.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">rvm -wrap <span class="code-quote">"&lt;wrapper-script-and-args&gt;"</span> &lt;<span class="code-keyword">rest</span> of command line&gt;</pre>
</div></div>
<p>For example, cachegrind can be invoked by</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">rvm -wrap <span class="code-quote">"/path/to/valgrind --tool=cachegrind"</span> &lt;java-command-line&gt;</pre>
</div></div>
<p>The command and arguments immediately after the &#45;wrap argument will be inserted into the script on the command line that invokes the boot image runner.&nbsp; One useful variant is</p>

<p><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">rvm -wrap echo &lt;<span class="code-keyword">rest</span> of command line&gt;</pre>
</div></div><br clear="all" />
<br clear="all" /></p>

<h2><a name="DebuggingtheRVM-%26nbsp%3BJavaPlatformDebuggerArchitecture%28JPDA%29"></a>&nbsp;<a href="http://java.sun.com/j2se/1.5.0/docs/guide/jpda/index.html">Java Platform Debugger Architecture (JPDA)</a></h2>

<p>In general the JPDA provides 3 mechanisms for debugging Java applications:</p>
<ul>
	<li>The <a href="http://java.sun.com/j2se/1.5.0/docs/guide/jpda/jdi/index.html">Java Debug Interface</a> is an API for debugging Java code from Java.</li>
	<li>The <a href="http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html">JVM Tools Interface</a> is an API for writing native/C code for debugging a JVM, it is similar to the Java Native Interface (JNI).</li>
	<li>The <a href="http://java.sun.com/j2se/1.5.0/docs/guide/jpda/jdwp-spec.html">Java Debug Wire Protocol</a> is a network protocol for debugging Java code running on JVMs.</li>
</ul>


<p>Currently JDWP code is being implemented in Jikes RVM based on the GNU Classpath implementation.</p>

				    
                    			    </td>
		    </tr>
	    </table>
	    <table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td height="12" background="http://docs.codehaus.org/images/border/border_bottom.gif"><img src="images/border/spacer.gif" width="1" height="1" border="0"/></td>
			</tr>
		    <tr>
			    <td align="center"><font color="grey">Document generated by Confluence on Jun 10, 2009 09:12</font></td>
		    </tr>
	    </table>
    </body>
</html>